<?php
/* MyMeeting is an online meeting management software.
 * Copyright (C) 2009 Government Of Malaysia
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * @author: Abdullah Zainul Abidin, Nuhaa All Bakry
 *          Eavay Javay Barnad, Sarogini Muniyandi
 *
 */


class DecisionsGroupsController extends AppController {

/**
 * Define $name
 *
 */
	var $name = 'DecisionsGroups';
/**
 * Define $helpers
 *
 */
	var $helpers = array('Html', 'Form');

/**
 * Describe index
 *
 * @return null
 */
	function index() {
		$this->DecisionsGroup->recursive = 0;
		$this->set('decisionsGroups', $this->paginate());
	}

/**
 * Describe view
 *
 * @param $id
 * @return null
 */
	function view($id = null) {
		if (!$id) {
			$this->flash(__('Invalid DecisionsGroup', true), array('action'=>'index'));
		}
		$this->set('decisionsGroup', $this->DecisionsGroup->read(null, $id));
	}

/**
 * Describe add
 *
 * @return null
 */
	function add() {
		if (!empty($this->data)) {
			$this->DecisionsGroup->create();
			if ($this->DecisionsGroup->save($this->data)) {
				$this->flash(__('DecisionsGroup saved.', true), array('action'=>'index'));
				exit();
			} else {
			}
		}
		$decisions = $this->DecisionsGroup->Decision->find('list');
		$groups = $this->DecisionsGroup->Group->find('list');
		$users = $this->DecisionsGroup->User->find('list');
		$this->set(compact('decisions', 'groups', 'users'));
	}

/**
 * Describe edit
 *
 * @param $id
 * @return null
 */
	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->flash(__('Invalid DecisionsGroup', true), array('action'=>'index'));
			exit();
		}
		if (!empty($this->data)) {
			if ($this->DecisionsGroup->save($this->data)) {
				$this->flash(__('The DecisionsGroup has been saved.', true), array('action'=>'index'));
				exit();
			} else {
			}
		}
		if (empty($this->data)) {
			$this->data = $this->DecisionsGroup->read(null, $id);
		}
		$decisions = $this->DecisionsGroup->Decision->find('list');
		$groups = $this->DecisionsGroup->Group->find('list');
		$users = $this->DecisionsGroup->User->find('list');
		$this->set(compact('decisions','groups','users'));
	}

/**
 * Describe delete
 *
 * @param $id
 * @return null
 */
	function delete($id = null) {
		if (!$id) {
			$this->flash(__('Invalid DecisionsGroup', true), array('action'=>'index'));
		}
		if ($this->DecisionsGroup->del($id)) {
			$this->flash(__('DecisionsGroup deleted', true), array('action'=>'index'));
		}
	}

}
?>
